import os
from openslide import OpenSlide, OpenSlideError
import argparse

def gen_thumbnail(input_path , output_path):
    # 缩略图的文件格式 (png 或 jpg)
    thumbnail_format = "png"

    slide = OpenSlide(
        input_path
    )

    thumbnail_image = slide.associated_images["thumbnail"]

    if thumbnail_format.lower() == "jpg" and thumbnail_image.mode == "RGBA":
        thumbnail_image = thumbnail_image.convert("RGB")
 
    thumbnail_image.save(output_path)

    # python c/c++ java Rust go javascript

# 变量 类型 函数 类 ——> 操作系统、数据结构、程序设计 ——> 数据分析、统计学原理.....

class A:
    def __init__(self):
        self.value = "hello world"
        print("init A")
        print(self.value)
    

if __name__ == "__main__":
    gen_thumbnail(
        input_path="/mnt/data1/zzy/LNM/Zhujiang-slide/2019-2021CRC/9178364c-3489-50d9-b5ec-03e2fc5129d4_041949.svs"
        , output_path="./test_thumbnail1.png")
    a = A()
    
    
